home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / rodent.zip / MOUSEVNT.PAS < prev    next >
Pascal/Delphi Source File  |  1987-10-19  |  2KB  |  71 lines

  1. PROGRAM mousevnt;                   { Illustrates mouse function 12 }
  2.  
  3. USES dos, crt, mouse;
  4.  
  5. TYPE mEvent = record                    { for recording mouse event }
  6.        event,
  7.        btnStatus,
  8.        horiz,
  9.        vert   : WORD;
  10.      END;
  11.  
  12. VAR  mous : mEvent;
  13.      m    : resetRec;
  14.  
  15. { ----------------------------------------------------------------- }
  16. PROCEDURE handler     { Mouse event handler called by device driver }
  17.    (Flags, CS, IP, AX, BX, CX, DX, SI, DI, DS, ES, BP : WORD);
  18.  
  19. INTERRUPT;
  20.  
  21. BEGIN
  22.   mous.event     := AX;
  23.   mous.btnStatus := BX;
  24.   mous.horiz     := CX;
  25.   mous.vert      := DX;
  26.   inline (        { Exit processing for far return to device driver }
  27.        $8B/$E5/            { MOV  SP, BP }
  28.        $5D/                { POP  BP }
  29.        $07/                { POP  ES }
  30.        $1F/                { POP  DS }
  31.        $5F/                { POP  DI }
  32.        $5E/                { POP  SI }
  33.        $5A/                { POP  DX }
  34.        $59/                { POP  CX }
  35.        $5B/                { POP  BX }
  36.        $58/                { POP  AX }
  37.        $CB );              { RETF    }
  38. END;
  39. { --------------------------- }
  40.  
  41. BEGIN
  42. { Set up screen }
  43.   CLRSCR;
  44.   GOTOXY (17, 25);
  45.   WRITE ('Press left button for position, right to quit');
  46.   GOTOXY (27, 1);
  47.   WRITELN ('MOUSE EVENT-HANDLING DEMO');
  48.  
  49. { Set up mouse }
  50.   mReset (m);
  51.   IF m.exists THEN BEGIN
  52.     mInstTask ($14, seg (handler), ofs (handler));
  53.     mous.event := 0;
  54.     mShow;
  55.  
  56. { Loop to perform demo }
  57.     REPEAT
  58.       IF mous.event = 4 THEN BEGIN
  59.         mHide;
  60.         WRITELN ('X = ', mous.horiz : 5, ', Y = ', mous.vert : 5);
  61.         mShow;
  62.         mous.event := 0;
  63.       END;
  64.     UNTIL mous.event = $10;
  65.  
  66. { Clean up and quit }
  67.     mHide;
  68.     mReset (m);
  69.   END;
  70.   CLRSCR;
  71. END.